package com.example.expandablelistview.network;

import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.widget.ScrollView;
import android.widget.TextView;

public class ConMgr extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		ScrollView root = new ScrollView(this);
		TextView tv = new TextView(this);

		LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT,
				LayoutParams.MATCH_PARENT);

		root.addView(tv, params);
		setContentView(root);

		StringBuilder sb = new StringBuilder();
		ConnectivityManager mgr = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);

		NetworkInfo[] ani = mgr.getAllNetworkInfo();

		for (NetworkInfo n : ani) {
			sb.append(n.toString() + "\n\n");
		}

		NetworkInfo ni = mgr.getActiveNetworkInfo();
		if (ni != null) {
			sb.append("Active : \n" + ni.toString() + "\n");
			tv.setText(sb);
			tv.setTextSize(20);
		}
	}
}
